package org.tls.ylt.user.receiver;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.tls.ylt.common.rabbit.constant.MqConst;
import org.tls.ylt.user.service.EmailService;
import org.tls.ylt.vo.email.EmailVo;

@Component
public class SmsReceiver {
    @Autowired
    private EmailService emailService;
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_EMAIL_ITEM, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_EMAIL),
            key = {MqConst.ROUTING_EMAIL_ITEM}
    ))
    public void send(EmailVo msmVo, Message message, Channel channel) {
        System.out.println("接收到MQ消息");
        emailService.send(msmVo);
    }
}
